package com.siki.controller;

import com.siki.config.filterConfig.jwtConfig.annotation.AdminLoginToken;
import com.siki.config.filterConfig.jwtConfig.annotation.UserLoginToken;
import com.siki.dto.admin.FindEnterpriseListDTO;
import com.siki.dto.admin.SumbitAuditStatusDTO;
import com.siki.service.AdminService;
import com.siki.utils.JsonInfoReturn;
import com.siki.vo.admin.FindAllEnterpriseVO;
import com.siki.vo.admin.FindEnterpriseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.hibernate.internal.build.AllowSysOut;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.awt.*;

/**
 * @Author Siki
 * @Date 2020/6/9
 */
@RestController
@Api(tags = "管理员用户相关操作模块")
@RequestMapping("/api/vi/siki/admin")
@CrossOrigin
@AdminLoginToken
public class AdminController {
    private AdminService adminService;

    public AdminController(AdminService adminService) {
        this.adminService = adminService;
    }

    @ApiOperation(value = "[查询接口] - 管理员按条件查询所有账号", consumes = "application/json",
            httpMethod = "POST", response = FindAllEnterpriseVO.class)
    @RequestMapping(value = "/get_list", method = RequestMethod.POST)
    public JsonInfoReturn getEnterpriseList(@RequestBody @Validated @ApiParam("条件查询账号DTO") FindEnterpriseListDTO dto) {
        return JsonInfoReturn.success(adminService.findAllEnterprise(dto));
    }

    @ApiOperation(value = "[查询接口] - 根据id查询账号详细信息", consumes = "application/json", httpMethod = "GET", response = FindEnterpriseVO.class)
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public JsonInfoReturn getEnterprise(@NotNull @PathVariable("id") String id) {
        return JsonInfoReturn.success(new FindEnterpriseVO(adminService.findAccount(id)));
    }

    @ApiOperation(value = "[提交接口] - 管理员审核企业账号提交", consumes = "application/json", httpMethod = "POST")
    @RequestMapping(value = "/sumbit_audit_status", method = RequestMethod.POST)
    public JsonInfoReturn sumbitAccountStatus(@RequestBody @Validated @ApiParam("管理员审核企业账号DTO") SumbitAuditStatusDTO dto,
                                              Authentication authentication) {
        adminService.sumbitAccountStatus(dto, authentication.getName());
        return JsonInfoReturn.success();
    }

    @ApiOperation(value = "[查询接口] - 管理员查询被投诉岗位", consumes = "application/json", httpMethod = "GET")
    @RequestMapping(value = "/get_complaint_list", method = RequestMethod.GET)
    public JsonInfoReturn getComplaintList() {
        adminService.getComplaintList();
        return JsonInfoReturn.success();
    }
}
